import {
    getUser,
    getAddressList
} from 'src/api/getData'
import * as types from './action-type';

// 获取用户信息
export const getUserInfo = () => async (dispatch, getState) => {
    try {
        let res = await getUser();
        dispatch({
            type: types.GET_USERINFO,
            info: res.data
        })
    } catch (error) {

    }
}
// 保存地址
export const saveAddress = () => async (dispatch, getState) => {
    try {
        const state = getState();
        if (state.removeAddress.length > 0) return;
        let address = await getAddressList(state.userInfo.user_id);
        dispatch({
            type: types.SAVE_ADDRESS,
            newAdress: address.data
        })
    } catch (error) {

    }
}